const path = require('path')
function resolve(dir) {
  return path.join(__dirname, dir)
}
module.exports = {
  devServer: {
    hot: true,
    compress: true,
    overlay: true,
    // historyApiFallback: {
    //   rewrites: [{ from: /^\/$/, to: '/index.html' }]
    // },
    proxy: {
      '/api': {
        target: process.env.VUE_APP_HTTP_API,
        changeOrigin: true,
        pathRewrite: {
          '^/api': 'api'
        }
      }
      // '/auth': {
      //   target: process.env.VUE_APP_HTTP_API,
      //   changeOrigin: true,
      //   pathRewrite: {
      //     '^/auth': 'auth'
      //   }
      // }
    }
  },
  chainWebpack: config => {
    config.module
      .rule('svg')
      .exclude.add(resolve('src/assets/svg-icon/'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/assets/svg-icon/'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()
    config.resolve.alias
      .set('@', resolve('src'))
      .set('app', resolve('src/app'))
      .set('assets', resolve('src/assets'))
      .set('components', resolve('src/components'))
      .set('constants', resolve('src/constants'))
      .set('enums', resolve('src/enums'))
      .set('mixins', resolve('src/mixins'))
      .set('i18n', resolve('src/i18n'))
      .set('services', resolve('src/services'))
      .set('styles', resolve('src/styles'))
      .set('utils', resolve('src/utils'))
      .set('views', resolve('src/views'))
  }
}
